﻿using Super_Management_Mayhem.Screens.Playing.Players;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.AttackModel
{
    public class UnidirectionalAttack : BaseAttack
    {
        private TE_Vector2 _direction;
        private float _velocity;


        public UnidirectionalAttack(TargetTeam targetType, Team targetTeam, IAttacker attackerObject, int damage, int hurtTime, TE_Rectangle attackBoundingBox, TE_Vector2 direction, float velocity) : base(targetType, targetTeam, attackerObject, damage, hurtTime, attackBoundingBox)
        {
            _direction = direction;
            _velocity = velocity;
        }

        public override bool Attack(IAttackable possibleTarget)
        {
            if (IsValidTarget(possibleTarget))
            {
                if(possibleTarget.Hit(_direction * _velocity, Attacker.GetPosition(), HurtTime, Damage))
                    Attacker.OnAttack();
            }

            return false;
        }

        public override void Attack(TE_Vector2 position)
        {
            Playscreen.Map.Attack(this, AttackBoundingBox + position);
        }
    }
}